#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+10,INF = 1e9;
template <typename T> void tomin(T& x,T y){x = min(x,y);}
template <typename T> void tomax(T& x,T y){x = max(x,y);}
//
int T,n,m,cnt;
ll L,V,d[N],v[N],a[N],p[N];

int mx[N];
void mdf(int L,int R){
    if(L>R)return;
    cnt++; tomax(mx[R],L);
}

int dp[N],qu[N],hd,rr;

void solve(){
    cin>>n>>m>>L>>V; cnt = 0;
    for(int i=1;i<=n;i++)cin>>d[i]>>v[i]>>a[i];
    for(int i=1;i<=m;i++)cin>>p[i];
    for(int i=0;i<=m+1;i++)mx[i] = -INF;

    //
    for(int i=1;i<=n;i++){
        if(a[i] == 0){
            if(v[i] > V){
                int L = lower_bound(p+1,p+1+m,d[i])-p;
                mdf(L,m);
            }
        }else if(a[i] > 0){
            if(v[i] > V){
                int L = lower_bound(p+1,p+1+m,d[i])-p;
                mdf(L,m);
            }else{
                int c = V - v[i];
                int L = 1,R = m,res = m+1;
                while(L<=R){
                    int mid = (L+R)>>1;
                    int len = p[mid] - d[i];
                    if(2ll*v[i]*c + 1ll*c*c < 1ll*2*a[i]*len)res = mid,R = mid-1;
                    else L = mid+1;
                }
                mdf(res,m);
            }
        }else{
            a[i] *= -1;
            if(v[i] <= V)continue;
            int lp = lower_bound(p+1,p+1+m,d[i])-p;
            int c = v[i] - V,L = 1,R = m,res = 0;
            while(L<=R){
                int mid = (L+R)>>1;
                int len = p[mid] - d[i];
                if(2ll*v[i]*c - 1ll*c*c > 1ll*2*a[i]*len)res = mid,L = mid+1;
                else R = mid-1;
            }
            mdf(lp,res);    
        }
    }
    //
    hd = rr = dp[0] = 0; qu[rr++] = 0;
    for(int i=1;i<=m;i++){
        dp[i] = dp[qu[hd]] + 1;
        while(hd<rr && qu[hd] < mx[i])hd++;
        while(hd<rr && dp[qu[rr-1]] >= dp[i])rr--;
        qu[rr++] = i;
    }
    int ans = m - dp[qu[hd]];
    cout<<cnt<<" "<<ans<<endl;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false); cin.tie(0);

    cin>>T;
    while(T--)solve();

    return 0;
}